package com.ww.springboot.boot.algorithm.leetcode1;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-03-28 17:02
 */
public class BD693 {

    public static void main(String[] args) {
        System.out.println(hasAlternatingBits(5));
    }

    public static boolean hasAlternatingBits(int n) {
        int m = n % 2;
        n /= 2;
        while (n > 0) {
            int m2 = n % 2;
            if (m2 == m) {
                return false;
            }
            m = m2;
            n /= 2;
        }
        return true;
    }
}
